//Copyright (C) 2012 Chirila Alexandru
//This file is part of Mirror FTP
//
//Mirror FTP is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//Mirror FTP is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with Mirror FTP.  If not, see <http://www.gnu.org/licenses/>.

#ifndef FILENODE_H_
#define FILENODE_H_

#include <list>
#include <queue>

#include <iostream>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

/**
 * Tree like structure that manages files that have been already downloaded
 * by the recursive algorithm
 */
class file_node {	///<Implements graph like structure for managing files
private:
	string name;	///<name
	string path;	///<full (path / name)
	string mdtm;	///<last modification date
	long long size; ///<size
	char type;		///<type
	bool check; 	///<true if file or directory has been completely processed
public:
	list<file_node*> children;	///<a list of the nodes children
	file_node();
	~file_node();
	void set_mdtm(string x){mdtm=x;};
	void set_name(string x){name=x;};
	void set_size(long long x){size=x;};
	void set_type(char x){type=x;};
	void set_path(string x){path=x;};
	string get_mdtm(){return mdtm;};
	string get_name(){return name;};
	string get_path(){return path;};
	long long get_size(){return size;};
	char get_type(){return type;};
	void add_child(char t,string n ,string p,long long s,string n_mdtm);
	void add_child(file_node* x){children.push_back(x);};
	void print_struct();
	void print_node();
	int check_in(string p);
	file_node* find_child_by_name(string name);
	void checked(){check=true;};
	bool is_checked(){return check;};

	void dump_to_xml(fstream *file);



};
#endif /* FILENODE_H_ */
